package com.hope.bubble.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hope.bubble.common.api.ApiResult;
import com.hope.bubble.model.entity.BubbleBoard;
import com.hope.bubble.service.IBubbleBoardService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件名：BubbleBoardController
 * 创建者：hope
 * 邮箱：1602774287@qq.com
 * 微信：hope4cc
 * 创建时间：2022/10/21-14:24
 * 描述：公告板
 */
@RestController
@RequestMapping("/bubbleboard")
public class BubbleBoardController extends BaseController {


    @Resource
    private IBubbleBoardService bubbleBoardService;

    @GetMapping("/show")
    public ApiResult<BubbleBoard> getNotices(){
        List<BubbleBoard> list=bubbleBoardService.list(new
                        LambdaQueryWrapper<BubbleBoard>().eq(BubbleBoard ::isShow,true));//返回为真的 也就show 字段为1
        //返回最后一条记录,这个公告,所以最后一条是最新的
        return ApiResult.success(list.get(list.size() - 1));
    }

}
